import request from '@/utils/request'
import Axios from 'axios'

export function getRoomList(page, size) {
    return request({
        url: '/item/room/list',
        method: 'get',
        params: {
            page,
            size
        }
    })
}


export function addRoom(name, remarks) {
    return request({
        url: '/item/room/save',
        method: 'post',
        data: JSON.stringify({
            name,
            remarks
        }),
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}

export function changeRoom(id, name, remarks) {
    return request({
        url: '/item/room/update',
        method: 'put',
        data: JSON.stringify({
            id,
            name,
            remarks
        }),
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}

export function deleteRoom(id) {
    return request({
        url: '/item/room/delete',
        method: 'delete',
        params: {
            id
        }
    })
}

export function getDeviceList(number) {
    return request({
        url: '/item/factoryDevice/list',
        method: 'get',
        params: {
            number
        }
    })
}

export function addDevice(number, label) {
    return request({
        url: '/item/factoryDevice/save',
        method: 'post',
        data: JSON.stringify({
            number,
            label
        }),
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}

export function changeDevice(id, label) {
    return request({
        url: '/item/factoryDevice/update',
        method: 'put',
        data: JSON.stringify({
            id,
            label
        }),
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}

export function deleteDevice(id) {
    return request({
        url: '/item/factoryDevice/delete',
        method: 'delete',
        params: {
            id
        }
    })
}

//数据
export function getDataList(page, size, deviceID, date) {
    return request({
        url: '/item/factorydata/oneDevice',
        method: 'get',
        params: {
            page,
            size,
            deviceID,
            date
        }
    })
}

export function deleteData(id) {
    return request({
        url: '/item/factorydata/delete',
        method: 'delete',
        params: {
            id
        }
    })
}

export function getWarnDataList(page, size, date) {
    return request({
        url: '/item/factorydata/abnormalMessage',
        method: 'get',
        params: {
            page,
            size,
            date
        }
    })
}

export function deleteWarnData(id) {
    return request({
        url: '/item/factorydata/deleteAbnormal',
        method: 'delete',
        params: {
            id
        }
    })
}

//manager

//修改密码
export function changePassword(id, password) {
    return request({
        url: '/item/user/update',
        method: 'put',
        data: JSON.stringify({
            id,
            password
        }),
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}

export function changeMoreMess(data) {
    return request({
        url: '/item/user/update',
        method: 'put',
        data: JSON.stringify(
            data
        ),
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}

export function getThreshold() {
    return request({
        url: '/item/factorydata/threshold',
        method: 'get'
    })
}

export function changeThreshold(data) {
    return request({
        url: '/item/factorydata/editThreshold',
        method: 'post',
        data: JSON.stringify(
            data
        ),
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}

//分页
